<?php

/**
 * Impress - Open source digital signage
 *
 * @link http://digitalsignage.tk
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 *
 * @category Impress
 * @package Impress
 */

/**
 * This class stores and restores messages that appears in application.
 *
 * @package Impress
 * @subpackage Core
 */

class ADS_MsgStack{
    
    private static $stack = array(
        'error'   => array(),
        'success' => array()
    );
    
    public static function push($type, $msg){
        if(!in_array($type, array('error','success'))){
            throw new InvalidArgumentException(sprintf('Wrong parameters for method %.',__METHOD__));
        }
        self::$stack[$type][] = $msg; 
    }
    
    public static function pop($type){
        if(!in_array($type, array('error','success'))){
            throw new InvalidArgumentException(sprintf('Wrong parameters for method %.',__METHOD__));
        }
        
        return array_pop(self::$stack[$type]); 
    }
    
    public static function getStack(){
        return self::$stack;
    }
    
}
